<template>
  <div >
    <div>
      <div class="links">
        <!-- 路由跳转1 -->
        <Button type="primary" to="/home">跳转方式1,跳转到home</Button>
        <!-- 路由跳转2 -->
        <Button type="primary" @click="toHehe">跳转方式2, 跳转到item</Button>
        <!-- 路由跳转3 -->
        <nuxt-link to="/home/item">跳转方式3</nuxt-link>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  created () {
    console.log('我是创建中')
    
  },
  mounted () {
    this.login();
    console.log(this.$router);
  },
  methods: {
    toHehe () {
        this.$router.push('/home/item');
    },
    hello () {
      this.$get('/api/useraccount/1').then(res => {
        console.log(res);
      }).catch(error => {
        console.log(error);
      })
      console.log('hello');
    },
    login () {
      this.$post('/api/login', {username: 'chenzhijun', password: '哈哈哈哈'}).then(res => {
        if (res.code === "00001") {
          sessionStorage.setItem('Bearer', res.data);
        }
      }).catch(error => {
        console.log(error);
      })
    },
  }
}
</script>

<style>
.container {
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.title {
  font-family: 'Quicksand', 'Source Sans Pro', -apple-system, BlinkMacSystemFont,
    'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  display: block;
  font-weight: 300;
  font-size: 100px;
  color: #35495e;
  letter-spacing: 1px;
}
.subtitle {
  font-weight: 300;
  font-size: 42px;
  color: #526488;
  word-spacing: 5px;
  padding-bottom: 15px;
}
.links {
  padding-top: 15px;
}
</style>
